package com.mystudyspring.studySpringBoot.util;

import com.mystudyspring.studySpringBoot.domain.ApiResultDto;
import com.mystudyspring.studySpringBoot.domain.ApiResultGenerator;
import org.springframework.web.bind.annotation.*;

/**
 * api全局异常处理
 *
 * @author lix
 * @create 2018-03-27 11:19
 */
@ControllerAdvice(annotations = RestController.class)
@ResponseBody
public class RestExceptionHandler {

    @ExceptionHandler
    @ResponseStatus
    public ApiResultDto runttimeExceptionHandler(Exception e) {
        return ApiResultGenerator.errorResult(e.getMessage(), e);
    }
}
